<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>05_流程控制</title>
</head>
<body>
<script>
    //1.顺序结构
    console.log('1');
    console.log('2');
    console.log('3');
    //2.分支结构
    let username = '1';
    if(!username){
        alert('用户名不能为空');
    }else{
        alert('用户名为：'+username);
    }
    //3.选择分支
    let gender = 3;
    switch (gender){
        case 1:
            console.log('男');
            break;
        case 2:
            console.log('女');
            break;
        default:
            console.log('未知');
    }
    //4.循环结构
    //for循环
    let names = ['张三','李四','王五'];
    for(let i=0;i<names.length;i++){
        console.log(names[i]);
    }
    //for...of循环 增强for循环
    for (let n of names){
        console.log(n);
    }

    //while循环
    let j = 0;
    while(j<5){
        console.log(j);
        j++;
    }
    //do...while循环


</script>
</body>
</html>